<div class="home_sidebar">
  <h1> Sections <h2>
</div>
<div class="home_sections">
  <div class="home_section">
    <h1> User Controls </h1>
    <div class="home_sub_section">
      <h2> Switch to User </h2>
      <div class="home_section_content">
        <p> 
          Select a volunteer from the list below to swtich to.
          After switching you will have logout and login to get back to your
          real user.
        </p>
        <%= form_tag("/volunteers/switch_user", :method => "get") do %>
        <table class>
          <tr>
            <td>Volunteer:</td>
            <% adminrids = current_volunteer.assignments.collect{ |a| a.admin ? a.region.id : nil }.compact
            if current_volunteer.super_admin? %>
            <td><%= select_tag(:volunteer_id, options_for_select(Volunteer.find(:all, :order => 'name').collect{ |v| 
                      ["#{v.name} ["+v.regions.collect{ |r| r.name }.join(",")+"]",v.id] })) %></td> 
            <% else %>
            <td><%= select_tag(:volunteer_id, options_for_select(Volunteer.find(:all, :order => 'name').collect{ |v| 
                      ((v.regions.collect{ |r| r.id } & adminrids).length > 0 and !v.admin) ? [v.name,v.id] : nil }.compact)) %></td>
            <% end %>
          </tr>
        </table>
        <%= submit_tag "Switch" %>
        <% end %>
      </div>
    </div>
    <div class="home_sub_section">
      <h2> Generate Receipts </h2>
      <div class="home_section_content">
      <%= form_tag("/logs/receipt.pdf", :method => "get") do %>
      <table>
      <tr>
        <td>Donor/Recipient:</td>
        <% adminrids = current_volunteer.assignments.collect{ |a| a.admin ? a.region.id : nil }.compact
        if current_volunteer.super_admin? %>
        <td><%= select_tag(:location_id, options_for_select(Location.where("region_id IN (#{current_volunteer.regions.collect{ |r| 
                 r.id }.join(",")})").collect{ |v| [v.name,v.id] })) %></td>
        <% else %>
        <td><%= select_tag(:location_id, options_for_select(Location.where("region_id IN (#{adminrids.join(",")})").collect{ |l|
                  [l.name,l.id] })) %></td>
        <% end %>
      </tr>
      <tr>
        <td>Starting On: </td>
        <td><%= select_date Date.today, :prefix => :start_date %></td>
      </tr>
      <tr>
        <td>Ending On: </td>
        <td><%= select_date Date.today, :prefix => :stop_date %></td>
      </tr>
    </table>
    <%= submit_tag "Generate" %>
<% end %>

      </div>
    </div>
    <% if current_volunteer.super_admin? %>
    <div class="home_sub_section">
      <h2> Toggle Super-Admin Priviledges </h2>
      <div class="home_section_content">
      <p>
      Super-admins can do most anything for any region. This should only be given to site 
      administrators. See <%= link_to assignments_path do "assignments" end %> to assign per-region admins.
      </p>
      <%= form_tag("/volunteers/knight", :method => "get") do %>
      <table>
      <tr>
        <td>Volunteer:</td>
        <td><%= select_tag(:volunteer_id, options_for_select(Volunteer.all.collect{ |v| 
                name = v.name + " [" + v.assignments.collect{ |a| (a.admin ? "*" : "") + a.region.name }.join(",") + "]"
                name = "*#{name}" if v.admin
                [name,v.id] 
                }))
            %></td>
      </tr>
    </table>
    <%= submit_tag "Toggle" %>
    <% end %>
      </div>
    </div>
    <% end %>
  </div>

  <div class="home_section">
    <h1> Pickup Stats </h1>
    <div class="home_sub_section">
      <h2> Pickup Stats </h2>
      <div class="home_section_content">
      </div>
    </div>
    <div class="home_sub_section">
      <h2> Food Collected by Day </h2>
      <div class="home_section_content">
      </div>
    </div>
    <div class="home_sub_section">
      <h2> Food Collected by Month </h2>
      <div class="home_section_content">
      </div>
    </div>
  </div>
  <div class="home_section">
    <h1>Additional Information</h1>
    <div class="home_sub_section">
      <h2> Your Info </h2>
      <div class="home_section_content">
      </div>
    </div>
    <div class="home_sub_section">
      <h2> Your Donor/Recipient Map </h2>
      <div class="home_section_content">
      </div>
    </div>
    <div class="home_sub_section">
      <h2> Next Meeting Info </h2>
      <div class="home_section_content">
      </div>
    </div>
  </div>
</div>
